import syRequest from "@/service"
import type { IReleaseAccommodation, IReservation } from "./AccommodationParams"

const rootUrl = "/accommodation"

/**
 * 发布
 * @returns
 */
export function releaseAccommodation(data: IReleaseAccommodation) {
  return syRequest.post({
    url: rootUrl + "/releaseAccommodation",
    data
  })
}

/**
 * 获取
 * @returns
 */
export function getAccommodation(longitude, latitude, limit, offset) {
  return syRequest.get({
    url: rootUrl + "/getAccommodation",
    params: {
      longitude,
      latitude,
      limit,
      offset
    }
  })
}

/**
 * 熱度获取
 * @returns
 */
export function getAccommodationByHot(limit, offset) {
  return syRequest.get({
    url: rootUrl + "/getAccommodationByHot",
    params: {
      limit,
      offset
    }
  })
}

/**
 * 模糊获取
 * @returns
 */
export function likeAccommodation(keyword, limit, offset) {
  return syRequest.get({
    url: rootUrl + `/likeAccommodation/${keyword}`,
    params: {
      limit,
      offset
    }
  })
}

/**
 * 收藏
 * @returns
 */
export function saveAccommodation(
  accommodation_id,
  accommodation_uid,
  method: "GET" | "POST" | "DELETE"
) {
  return syRequest.request({
    method,
    url: rootUrl + `/saveAccommodation`,
    params: {
      accommodation_id,
      accommodation_uid
    }
  })
}

/**
 * 获取收藏
 * @returns
 */
export function getSaveAccommodation(limit, offset) {
  return syRequest.get({
    url: rootUrl + `/getSaveAccommodation`,
    params: {
      limit,
      offset
    }
  })
}

/**
 * 预约
 * @returns
 */
export function reservation(data: IReservation, method: "POST" | "DELETE") {
  return syRequest.request({
    method,
    url: rootUrl + `/reservation`,
    data
  })
}

/**
 * 获取预约
 * @returns
 */
export function getReservation(limit, offset) {
  return syRequest.get({
    url: rootUrl + "/getReservation",
    params: {
      limit,
      offset
    }
  })
}
